﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using l1cs.server.model.Instance;

namespace l1cs.server.serverpackets
{
    public class S_NewCharPacket : ServerBasePacket
    {
        private byte[] _byte = null;

        public S_NewCharPacket( L1PcInstance pc )
        {
            buildPacket( pc );
        }

        private void buildPacket( L1PcInstance pc )
        {
            writeC( Opcodes.S_OPCODE_NEWCHARPACK );
            writeS( pc.getName() );
            writeS( "" );
            writeC( pc.getType() );
            writeC( pc.get_sex() );
            writeH( pc.getLawful() );
            writeH( pc.getMaxHp() );
            writeH( pc.getMaxMp() );
            writeC( pc.getAc() );
            writeC( pc.getLevel() );
            writeC( pc.getStr() );
            writeC( pc.getDex() );
            writeC( pc.getCon() );
            writeC( pc.getWis() );
            writeC( pc.getCha() );
            writeC( pc.getInt() );

            // is Administrator
            // 0 = false
            // 1 = true , can't attack
            // > 1 true , can't attack
            // can use Public GameMaster Command
            // if (pc.isGm()) {
            // writeC(1);
            // } else {
            writeC( 0 );
            // }
        }

        override
        public byte[] getContent()
        {
            if ( _byte == null )
            {
                _byte = _bao.ToArray();
            }
            return _byte;
        }

        override
        public String getType()
        {
            return "[S] New Char Packet";
        }
    }
}
